// 首页
// http://18003.wsadqq.com/

// 登录
// http://18003.wsadqq.com/#/pages/login/login

// 接单
// http://18003.wsadqq.com/17013/order/getOrderByStatus


// 首页
let token = Android.getMap("token")
localStorage.setItem("token", token)


// 获取tokeN
function getAndroidToken() {
    let token = localStorage.getItem("token").replace(/^"|"$/g, '');
    return token
}
getAndroidToken()




// 接单
function getParameterHandler() {
    let headers = {
        "auth-token": parameter.getMap("token")
    }
    let body = {}
    let strUrl = `?curPage=1&perPage=10&status=4`
    let url = parameter.getMap("url") + strUrl
    return {
        mediaType: "json",
        requestType: "GET",
        url: url,
        headers: JSON.stringify(headers),
        body: JSON.stringify(body)
    }
}
getParameterHandler()


// 处理返回数据
function getResponse() {
    let res = response.getMap("res")
    let code = "500"
    let message = "接单中"

    res = JSON.parse(res)
    if (res["code"] == 0 && res["data"]["count"] > 0) {
        code = "200"
        message = "接单成功，请尽快完成"
    } else if (res["code"] == 0 && res["data"]["count"] <= 0) {
        code = "500"
        message = "接单中"
    } else {
        code = "300"
        message = res["message"]
    }

    return {
        code: code,
        message: message,
        dataKey: "",
        dataValue: ""
    }
}
getResponse()

// {
// 	"code": 0,
// 	"data": {
// 		"count": 0,
// 		"rows": []
// 	}
// }